<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <script src="./lib/vue-router-3.0.1.js"></script>
    <style>
        .aaa{
            color: red;
            font-weight: 800;
            font-style: italic;
            font-size: 14px;
            text-decoration: underline;
            background-color: skyblue;
        }
        .v-enter,
        .v-leave-to{
            opacity: 0;
            transform: translateX(140px);
        }
        .v-enter-active,
        .v-leave-active{
            transition: all 0.5s ease;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- <a href="#/login">登录界面</a>
            <a href="#/register">注册界面</a> -->
        <router-link to='/login?id=10&name=feng' tag="span">登录</router-link>
        <router-link to='/register'>注册界面</router-link>
       <transition mode="out-in">
           <router-view></router-view>
       </transition>

    </div>

    <script>
        var login = {
            //组件的模板对象。
            template: '<h1>登录组件---{{$route.query.id}}{{$route.query.name}}</h1>',
            data(){
                return{
                    msg:'123'
                }
            },
            created(){
                console.log(this.$route.query.id)
            }
        }
        var register = {
            //组件的模板对象。
            template: '<h1>注册组件</h1>'
        }

        var vueobj = new VueRouter({
            routes: [
                // { path: '/login', component: login },
                { path: '/login', component: login },
                { path: '/register', component: register },
                // {path:'/', component:login}
                {path:'/', redirect:'/login'}
                
            ],
            linkActiveClass: 'aaa'
        })

        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
            router: vueobj
        });
    </script>
</body>

</html>